package com.itheima.dao;


import com.itheima.pojo.Admin;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.Map;

public interface AdminMapper extends Mapper<Admin> {


    /**
     * 通过username查询admin
     * @param username
     * @return
     */
    @Select("select * from t_admin where user_name=#{username}")
    Admin findAdminByUsername(@Param("username") String username);

    @Select("select role_uid roleUid,avatar from t_admin where user_name=#{username}")
    Map<String, Object> findRoleIdAndAvatar(@Param("username") String username);

    @Select("select user_name userName,last_login_time lastLoginTime,role_uid roleUid from t_admin where  uid=#{uid}")
    Map<String,Object> findUserNameAndLoginTime(@Param("uid") String uid);

    @Select("select user_name userName,role_uid roleUid ,pass_word passWord,nick_name nickName,gender,avatar,email,login_count loginCount,last_login_time lastLoginTime,last_login_ip lastLoginIp,uid,status,create_time createTime,update_time updateTime from t_admin where  uid=#{adminUid}")
    Admin findAdminByUid(@Param("adminUid") String adminUid);

}
